const s = new Set();

[2, 3, 5, 4, 5, 2, 2].forEach(x => s.add(x));

for (let i of s) {
    console.log(i);
} // 2 3 5 4

set = new Set([1, 2, 3, 4, 4]); //Set 函数可以接受一个数组（或类似数组的对象）作为参数，用来初始化

set = new Set([1, 2, 3, 4, "4"]);
console.log(set);  // Set { 1, 2, 3, 4, '4' }


let a = new Set([1, 2, 3]);
let b = new Set([4, 3, 2]);

// 并集
let union = new Set([...a, ...b]);
console.log(union); // Set {1, 2, 3, 4}

// 交集
let intersect = new Set([...a].filter(x => b.has(x)));
console.log(intersect); // set {2, 3}

// 差集
let difference = new Set([...a].filter(x => !b.has(x)));
console.log(difference); // Set {1}


// Map
var map = new Map([
    ['name', '张三'],
    ['title', 'Author']
]);

console.log(map.size); // 2
console.log(map.has('name')); // true
console.log(map.get('name')); // "张三"
console.log(map.has('title')); // true
console.log(map.get('title')); // "Author"



